import { ImageResponse } from "next/og"; import { Mark } from "@/components/brand"; import { api } from "@/lib/api"; import { fmtScore, utcDateTime } from "@/lib/format"; export const runtime = "nodejs"; export const alt = "WebSensor event"; export const size = { width: 1200, height: 630 }; export const contentType = "image/png"; const BG = "#0a0e15"; const PANEL = "#10161f"; const LINE = "#2d394e"; const FG = "#e6e8ee"; const MUTED = "#a3adc2"; const SUBTLE = "#6b7591"; const SIGNAL = "#22d3a5"; const HOT = "#ff5c5c"; const HIGH = "#ff9640"; const MID = "#e4b53b"; const SILENT = "#a78bfa"; function scoreColor(v: number): string { return v >= 90 ? HOT : v >= 75 ? HIGH : v >= 50 ? MID : SUBTLE; } function clip(s: string, max: number): string { return s.length > max ? s.slice(0, max - 1).trimEnd() + "…" : s; } export default async function OpenGraphImage({ params }: { params: Promise<{ slug: string }> }) { const { slug } = await params; const d = await api.event(slug); const e = d?.event ?? null; const signal = e ? Math.round(e.signal_score ?? e.importance) : 0; const badges: { label: string; color: string }[] = []; if (e?.cluster?.state === "breaking") badges.push({ label: "BREAKING", color: HOT }); if (e?.cluster?.state === "developing") badges.push({ label: "DEVELOPING", color: HIGH }); if (e?.silent_change) badges.push({ label: "SILENT", color: SILENT }); if (e && e.first_party !== false) badges.push({ label: "FIRST PARTY", color: SIGNAL }); if (e?.first_party === false) badges.push({ label: "EXTERNAL", color: SUBTLE }); if (e?.evidence_label === "CONFIRMED") badges.push({ label: "CONFIRMED", color: SIGNAL }); const title = e ? clip(e.title, 150) : "Event not found"; const fontSize = title.length > 110 ? 40 : title.length > 70 ? 46 : 54; return new ImageResponse( (